﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Migrations;
using PublicCommon;
using T_settlement.Domain;
using T_settlement.Read.API.Application.Command.InvoiceCommand;
using T_settlement.Read.API.Application.Command.OutputCommand;
using T_settlement.Read.API.Application.Command.PaymentCommand;
using T_settlement.Read.API.Application.Command.PayMoneyCommand;
using T_settlement.Read.API.Application.Command.TollCommand;

namespace T_settlement.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SettlementController : ControllerBase
    {
        private readonly IMediator  mediator;

        public SettlementController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 显示收费用信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<PageResult<Settlement>> GetSettlement([FromQuery]GetTollCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }
       

        /// <summary>
        /// 反填收费用信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<Settlement> FanSettlement([FromQuery] FanTollCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 显示付费信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<PageResult<PayMoney>> GetPayMoney([FromQuery] GetPayMoneyCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 反填付费信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<PayMoney> FanPayMoney([FromQuery] FanPayMoneyCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }







        /// <summary>
        /// 显示进项发票信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<PageResult<Invoice>> GetInvoice([FromQuery] GetInvoiceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 反填进项发票信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<Invoice> FanInvoice([FromQuery] FanInvoiceCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }


        /// <summary>
        /// 显示销项发票信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<PageResult<Output>> GetOutput([FromQuery] GetOutputCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {

                throw;
            }
        }


        /// <summary>
        /// 反填销项发票信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]

        public async Task<Output> FanOutput([FromQuery] FanOutputCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }



        /// <summary>
        /// 显示付款信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<PageResult<Payment>> GetPayment([FromQuery] GetPaymentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }


        /// <summary>
        /// 显示付款信息(判断状态)
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<PageResult<Payment>> GetStatePayment([FromQuery] StateGetPaymentCommand command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 反填付款信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public async Task<Payment> FanPaymnet([FromQuery] FanPaymentCommnad command)
        {
            try
            {
                return await mediator.Send(command);
            }
            catch (Exception)
            {
                throw;
            }
        }  
    }
}
